package net.jwtools.tmt.dao.hibernate;

import java.util.List;

import net.jwtools.tmt.domain.IVisit;
import net.jwtools.tmt.domain.Person;
import net.jwtools.tmt.domain.Status;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

public class PersonHibernateDAO extends AbstractSpringDao {
	
	public Person findByName(Long id) {
		return (Person) super.find(Person.class, id);
	}

	public Person findById(Long id) {
		return (Person) super.find(Person.class, id);
	}

	public void saveOrUpdate(Person person) {
		super.saveOrUpdate(person);
	}

	public void delete(Person person) {
		super.delete(person);
	}

	@SuppressWarnings("unchecked")
	public List<Person> findAll() {
		return (List<Person>) super.findAll(Person.class);
	}
	
	@SuppressWarnings("unchecked")
	public List<Person> findAllActive() {
		DetachedCriteria crit = DetachedCriteria.forClass(Person.class);
		crit.add(Restrictions.eq("status", Status.ACTIVE));
		return (List<Person>) super.findByCriteria(crit);
	}

	
}
